package com.gw.vip.server.service.dao_service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gw.vip.server.dao.HisOrderMapper;
import com.gw.vip.server.po.HisOrder;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

/**
 * @author GW
 * @description
 * @since 2022-05-05
 */
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class HisOrderService extends ServiceImpl<HisOrderMapper, HisOrder> {

    private final HisOrderMapper mapper;

    /**
     * 根据店铺号和客户号获取订单
     * @param shopId
     * @param clientOrder
     * @return
     */
    public HisOrder getByBase(String shopId, String clientOrder) {
        QueryWrapper<HisOrder> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(HisOrder::getShopId, shopId);
        queryWrapper.lambda().eq(HisOrder::getClientOrder, clientOrder);
        return getOne(queryWrapper);
    }

    public int countByClearDate(LocalDate clearDate) {
        return this.mapper.countByClearDate(clearDate);
    }

    public void tmpTransToHis(LocalDate clearDate) {
        this.mapper.tmpTransToHis(clearDate);
    }
}
